import requests;
import time;
import threading;
from proxyDemo.datas import IPPOOL;
from requests.packages import urllib3;
import json
class GetIpThread(threading.Thread):
    def starts(self):
        print("-------------------------------------------------")
        
        # 获取IP列表
        apiUrl = "http://gec.ip3366.net/api/?key=" #请自行修改接口
        res = requests.get(apiUrl)
        # 按照\n分割获取到的IP
        ip_list = json.loads(res.text)
        # print(res.text)
        for ip_dic in ip_list:
            ip = ip_dic.get('Ip')
            port = ip_dic.get('Port')
            ip_address = str(ip) + ':' + str(port)
            IPPOOL.append(ip_address)
        time.sleep(5)
        # IPPOOL = res.split('\n')
        # 休眠